<div id="channel_tb">
    <label>支付场景:</label>
    <input  id="gsxz_combobox" name="payScene" style="width:135px;">
    <label>支付公司:</label>
    <select id="companyName" class="easyui-combobox" name="companyName" style="width:135px;">
        <option value=""></option>
        <@company>
            <#list companyList as company>
                <option value="${company.companyName}">${company.companyName}</option>
            </#list>
        </@company>
    </select>
    <label>业务范围:</label>
    <input  id="jyfw_combobox" name="type" style="width:135px;">
    <label>使用设备:</label>
    <input  id="sysb_combobox" name="deviceName" style="width:135px;">
    <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="searchCondition()">查询</a>
</div>
<table id="channel_dg">
</table>
<#include "/WEB-INF/views/include/common.ftl"/>
<script type="text/javascript">
    var channel_dg;
    $(function () {
        channel_dg = $('#channel_dg');
        channel_dg.datagrid({
            url: '${ctx}/offer/searchChannel',
            fitColumns: true,
            pagination: true,
            rownumbers: true,
            pageSize: 10,
            pageList: [10, 20, 30],
            idField:'id',
            columns: [
                [{
                    field:'id',
                    title:'id',
                    checkbox: true
                },{
                    field: 'companyName',
                    title: '支付公司',
                    width: 100
                },{
                    field: 'productName',
                    title: '产品名称',
                    width: 100
                }, {
                    field: 'payScene',
                    title: '支付场景',
                    width: 100
                }, {
                    field: 'deviceName',
                    title: '设备',
                    width: 100,
                    formatter: function (value, row, index) {
                        var res = "";
                        if (value == 1) {
                            res = "移动端";
                        } else if (value == 2) {
                            res == "PC";
                        } else {
                            res = "其他";
                        }
                        return res;
                    }
                }, {
                    field: 'offerType',
                    title: '报价方式',
                    width: 100,
                    formatter: function (value, row, index) {
                        var res = "";
                        if (value == 1) {
                            res = "固定按单";
                        } else if (value == 2) {
                            res == "固定比例"
                        } else if (value == 3) {
                            res = "阶梯按单";
                        } else if (value == 4) {
                            res = "阶梯比例";
                        }
                        return res;
                    }
                }, {
                    field: 'offerPrice',
                    title: '恒生价格',
                    width: 100
                }, {
                    field: 'offerPartyPrice',
                    title: '第三方价格',
                    width: 100
                }, {
                    field: 'fengding',
                    title: '封顶',
                    width: 100
                }, {
                    field: 'fengdi',
                    title: '封底',
                    width: 100
                }, {
                    field: 'accountTime',
                    title: '清算周期',
                    width: 100,
                    sortable:true
                }, {
                    field: 'conditions',
                    title: '接入条件',
                    width: 100,
                }, {
                    field: 'supportBank',
                    title: '支持银行',
                    width: 100,
                    sortable:true
                }]
            ],
            toolbar: '#channel_tb'
        });
    });
    $(function () {
        $("#gsxz_combobox").combobox({
            url: '${ctx}/sys/findDicts/gsxz',
            valueField: 'valueField',
            textField: 'textField',
            multiple:true
        });

        $("#jyfw_combobox").combobox({
            url: '${ctx}/sys/findDicts/jyfw',
            valueField: 'valueField',
            textField: 'textField',
            multiple:true
        });

        $("#sysb_combobox").combobox({
            url: '${ctx}/sys/findDicts/sysb',
            valueField: 'valueField',
            textField: 'textField',
            multiple:true
        });
    });

    function searchCondition() {
        var data = $("#condition").serialize();
        channel_dg.datagrid({
            queryParams: {
                payScene:$("#gsxz_combobox").combobox('getText'),
                type:$("#jyfw_combobox").combobox('getText'),
                companyName:$("#companyName").combobox('getText'),
                deviceName:$("#sysb_combobox").combobox('getText')
            }
        });
        channel_dg.datagrid("reload");
    }

    function countCondition(){
        var selectRows = channel_dg.datagrid('getSelections');
        if(selectRows == null || selectRows.length == 0){
            $.messager.show({
                title : '提示信息',
                msg : '请选择一条记录',
                timeout : 1000 * 2
            });
            return false;
        }

        var ids =[];
        $.each(selectRows, function(i,val){
            ids[i] = val.id;
        });

        console.info(ids);
        parent.$.modalDialog.openner = channel_dg;
        parent.$.modalDialog({
            title: "输入预估值",
            width: 300,
            height: 200,
            href: "${ctx}/offer/countConditionUI/"+ids
        });
    }
</script>
